#pragma once
#include "IStream.h"

NAMESPACE_CORE_BEGIN

class CByteStream : public IOStream
{
public:
	CByteStream();
	CByteStream(int_x iLength);
	CByteStream(uint_8 * pArray, int_x iLength, bool bAutoDelete = false);
	~CByteStream();

	void ResetByteArray(uint_8 * pArray, int_x iLength, bool bAutoDelete = false);

	int_x ReadAviliable();
	uint_8 ReadUInt8();
	int_x ReadUInt8Array(uint_8 * pArray, int_x iLength);

	int_x WriteAviliable();
	void WriteUInt8(uint_8 byte);
	int_x WriteUInt8Array(const uint_8 * pArray, int_x iLength);
	void Flush();
	
	bool SeekSurpport(StreamSeek seek) const;
	int_x Seek(StreamSeek seek, int_x iSeek);

	uint_8 * GetBuffer();
	const uint_8 * GetBuffer() const;

private :
	uint_8 * m_pArray;
	int_x m_iLength;
	int_x m_iPosition;

	bool m_bAutoDelete;
};

NAMESPACE_CORE_END
